﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;



namespace Enough.Converter
{
    /// <summary>
    /// Value converter for concerting strings to UPPERCASE
    /// </summary>
    public class DateAbbreviationConverter : IValueConverter
    {
        //private static DateTimeFormatter formatter = new DateTimeFormatter(YearFormat.Default, MonthFormat.Default, DayFormat.Default, DayOfWeekFormat.None);
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return null;
            }
            DateTime dt;
            if (value is DateTimeOffset)
            {
                dt = ((DateTimeOffset)value).LocalDateTime;
            }
            else if (value is DateTime)
            {
                dt = (DateTime)value;
            }
            else
            {
                return value;
            }
            return dt.ToShortDateString();
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
